Skip to content

[v6] #507 - CSV readers: the error output of a line that cannot be read has its line number and values - #508

Draft
njoubert-cleverage wants to merge 1 commit into
mainfrom
507
Draft

njoubert-cleverage wants to merge 1 commit into
mainfrom
507

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #507 (v6.0):

  • CsvResource::readLine() throws an InvalidCsvLineException (extends UnexpectedValueException, so existing catches still work) carrying the values read by fgetcsv() (null when the line cannot be parsed);
  • CsvReaderTask (and InputCsvReaderTask) sets the error output of a line that cannot be read to ['csv_file' => <path>, 'csv_line' => <physical line number>, 'csv_values' => <values>], and adds csv_file / csv_line to the error context before reading the line (they were missing from the logged error);
  • reference pages of both readers (error output, example writing the invalid lines to a rejects file), CHANGELOG, UPGRADE.md (input_csv_reader no longer sends the file path to its error branch).

Checked locally: tests with pcov coverage (no risky test), PHPStan, PHP-CS-Fixer and Rector OK. Also run in the demo on the input file of a catalog import (input_csv_reader, error_strategy: skip, error branch on a csv_writer): the rejects file gets …/catalog_2026-11-24.csv;13;Carrie|Stephen, and the logged error has csv_file and csv_line in its context.

Requirements

  • Documentation updates
    • Reference
    • Cookbooks
    • Changelog
  • Unit tests

Breaking changes

The error output of input_csv_reader on a line that cannot be read is no longer its input (the file path, still available as csv_file), see UPGRADE.md.

🤖 Generated with Claude Code

…s its line number and values

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSV readers: the error output of a line that cannot be read has its line number and values

1 participant